<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>随机图片</title>
</head>

<body>
    <script>
        function ranNum() {
            var num = Math.round(Math.random() * 4+1);
            var source="<img src='img/a"+num+".gif'>";
            document.getElementById("d1").innerHTML += source;
        }
        var x="现在是："
        var t=Date();
        var mydate=new Date();
        document.write(x+t,"<br>");
        document.write(mydate.getFullYear(),"<br>");
        document.write(mydate.getMonth(),"<br>");
        document.write(mydate.getDate(),"<br>");
        document.write(mydate.getHours(),"<br>");
        document.write(mydate.getMinutes(),"<br>");
        document.write(mydate.getSeconds(),"<br>");
        document.write(mydate.getDay(),"<br>");
        document.write(mydate.toLocaleString(),"<br>");
    </script>
    <div id="d1">
    </div>
    <input type="button" value="随机数" onclick="ranNum()">
</body>

</html>